import 'package:aliyun_push/aliyun_push.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:aliyun_push/aliyun_push.dart' as AliYunPush;

void main() {

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    FlutterAliYun flutterAliYun=FlutterAliYun()..init();
    flutterAliYun.initCloudChannelResult.listen((data) {
      print(
          "----------->init successful ${data.isSuccessful} ${data.errorCode} ${data.errorMessage}");
    });
    flutterAliYun.onNotification.listen((data) {
      print("----------->notification here ${data.summary}");
    });
    flutterAliYun.onMessageArrived.listen((data) {
      print("----------->received data  ->${data.title} ${data.content}");
    });
  }



  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}
